package VN.EDU.IMIC.DEVELOPER.TRANTHITHANHNGA.EXJSON;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.accessibility.AccessibleStateSet;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JButton;

import org.codehaus.jackson.JsonGenerationException;
import org.codehaus.jackson.map.JsonMappingException;
import org.codehaus.jackson.map.ObjectMapper;

import vn.edu.imic.XmlProcess.XMLManagements;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class Choice extends JFrame {

	private JPanel contentPane;
	private static List<Students> StudentLs;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					Choice frame = new Choice(StudentLs);
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */

	public Choice(final List<Students> StudentLs) {

		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 170);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);

		JButton btnJson = new JButton("JSON");
		btnJson.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {

				String Path = "C:\\JSONFiles\\ListToJSONFiles.json";

				try {
					ObjectMapper objMapper = new ObjectMapper();
					objMapper.writeValue(new File(Path), StudentLs);
					System.out.println("ok");
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		});
		btnJson.setBounds(31, 71, 89, 23);
		contentPane.add(btnJson);

		JButton btnXml = new JButton("XML");
		
		btnXml.setBounds(159, 71, 89, 23);
		contentPane.add(btnXml);

		JButton btnCancel = new JButton("Cancel");
		btnCancel.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				System.exit(0);
			}
		});
		btnCancel.setBounds(289, 71, 89, 23);
		contentPane.add(btnCancel);
	}

}
